﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Win7Helper.Helper
{
    class TextHelper
    {
        /// <summary>
        /// 读取文本文件的方法
        /// </summary>
        /// <param name="FilePath">文件路径</param>
        /// <param name="defaultcoding">文件编码格式，默认utf8</param>
        /// <returns></returns>
        public static string ReaderText(string FilePath, Encoding defaultcoding = null)
        {

            String Readtext = "";
            Encoding ReadCoding = Encoding.UTF8;
            if (defaultcoding != null)
                ReadCoding = defaultcoding;
            try
            {
                Readtext = File.ReadAllText(FilePath, ReadCoding);

            }
            catch (Exception ex)
            {
                PrintLog.Log(ex);
                PrintLog.Log("传入的参数为FilePath{0}", FilePath);
            }
            return Readtext;
        }
    }
}
